package wu.com;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Yonghuzhuce {
    public static boolean login(String id,String password, String sex, String phone,String email) {
        Connection connection = null;
        Statement statement = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/yonghuxinxi", "root", "0804");
            statement = connection.createStatement();
            String sql = "INSERT INTO `yonghuxinxi`.`yonghu` (`id`, `password`, `sex`, `phone`, `email`) VALUES ('" + id + "', +'"+password+"',+'"  + sex + "', '"  + phone + "', '" + email + "')";
            int i = statement.executeUpdate(sql);
            if (i > 0) {
                return true;
            } else {
                return false;
            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                statement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return false;
    }
}
